<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./src/react.js"></script>
    <script src="./src/react-dom.js"></script>
    <script src="./src/babel.js"></script>
</head>
<style>
    .red{
        color: red;
    }
</style>
<body>
    <div id="app"></div>
</body>
<script type="text/babel">
function One(){
    return <div>选项一的内容</div>
}
    class Tab extends React.Component{
        constructor(){
            super();
            this.state={
                n:111,
                flag:1,
                zujian:<One></One>
            }
            
        }
        changeTab(n){
            console.log(n);
            this.setState({
                flag:n
            })
            switch(n){
                case 1:
                this.setState({
                    zujian:<div>选项一的内容</div>
                })
                break;
                case 2:
                this.setState({
                    zujian:<div>选项二的内容</div>
                })
                break;
                case 3:
                this.setState({
                    zujian:<div>选项三的内容</div>
                })
                break;
                default:
                this.setState({
                    zujian:<div>选项三的内容</div>
                });
                break;
            }
        }
        render(){
            return(
                <ul>
                <li className={this.state.flag==1?'red':''} onClick={()=>this.changeTab(1)}>页面1</li>
                <li className={this.state.flag==2?'red':''} onClick={()=>this.changeTab(2)}>页面2</li>
                <li className={this.state.flag==3?'red':''} onClick={()=>this.changeTab(3)}>页面3</li>
                <li>{this.state.zujian}</li>
            </ul>
            )
        }
    }
    ReactDOM.render(
    <Tab></Tab>,
    document.getElementById('app')
    )
</script>

</html>